package net.liteheaven.hidefix;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class ReflectionHelper {

    static {
        //System.loadLibrary("hidefix");
    }

    public static native void init();

    public static Method getMethod(Class<?> clazz, String name, Class<?> ... args){
        try {
            Method method = clazz.getMethod(name, args);
            return method;
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static Method getDeclaredMethod(Class<?> clazz, String name, Class<?> ... args){
        try {
            Method method = clazz.getDeclaredMethod(name, args);
            return method;
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static Field getDeclaredField(Class<?> clazz, String name){
        try {
            Field method = clazz.getDeclaredField(name);
            return method;
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    public static Field getField(Class<?> clazz, String name){
        try {
            Field method = clazz.getField(name);
            return method;
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
